/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package SPARQL;

import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
 *
 * @author mirko
 */
public class Service {

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 41 * hash + Objects.hashCode(this.triplePatterns);
        hash = 41 * hash + Objects.hashCode(this.uri);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Service other = (Service) obj;
        if (!Objects.equals(this.triplePatterns, other.triplePatterns)) {
            return false;
        }
        if (!Objects.equals(this.uri, other.uri)) {
            return false;
        }
        return true;
    }
    
    private Set<TriplePattern> triplePatterns;
    private SimpleURI uri;

    public Set<TriplePattern> getTriplePatterns() {
        return triplePatterns;
    }

    public void setTriplePatterns(Set<TriplePattern> triplePatterns) {
        this.triplePatterns = triplePatterns;
    }

    public SimpleURI getUri() {
        return uri;
    }

    public void setUri(SimpleURI uri) {
        this.uri = uri;
    }

    public Service(SimpleURI uri) {
        this.uri = uri;
        this.triplePatterns = new HashSet<TriplePattern>();
    }
    
    public void addTriple(TriplePattern triple){
        this.triplePatterns.add(triple);
    }

    @Override
    protected Object clone(){
        Service newService = new Service((SimpleURI)uri.clone());
        for (TriplePattern triple : this.triplePatterns)
            newService.addTriple((TriplePattern) triple.clone());
        return newService; //To change body of generated methods, choose Tools | Templates.
    }
    
}
